/**
 * Module:  module_uart
 * Version: 1v1
 * Build:   0ddac49116f3de7724075e8518932a0494c5460f
 * File:    uart.h
 *
 * The copyrights, all other intellectual and industrial 
 * property rights are retained by XMOS and/or its licensors.
 * Terms and conditions covering the use of this code can
 * be found in the Xmos End User License Agreement.
 *
 * Copyright XMOS Ltd 2010
 *
 * In the case where this code is a modification of existing code
 * under a separate license, the separate license terms are shown
 * below. The modifications to the code are still covered by the 
 * copyright notice above.
 *
 **/                                   
#ifndef _uart_h_
#define _uart_h_
#include <xs1.h>

#ifndef __XC__
#include <xccompat.h>
#endif

#ifndef UART_BIT_RATE
#define UART_BIT_RATE 115200 // e.g. 9600, 38400, 115200, 460800
#endif

#define UART_BIT_TIME (XS1_TIMER_HZ / UART_BIT_RATE)

/********************************************************************/
/* BASIC UART I/O Function                                          */
/********************************************************************/
#ifdef __XC__
void uart_tx(port TXD, streaming chanend txData_chan);
void uart_rx(port RXD, streaming chanend rxData_chan);
void uart_module_start(streaming chanend mox, streaming chanend rxc1, streaming chanend rxc2, streaming chanend txc1, streaming chanend txc2, port rx, port tx);
void mox_handler(streaming chanend mox, streaming chanend rxc, streaming chanend txc);
signed chan_in_noblock(streaming chanend c);
#else
void uart_tx(port TXD, chanend txData_chan);
void uart_rx(port RXD, chanend rxData_chan);
void uart_module_start(chanend mox, chanend rxc, chanend rxc1, chanend txc, chanend txc1, port tx, port rx);
void mox_handler(chanend mox, chanend rxc, chanend txc);
signed chan_in_noblock(chanend c);
#endif


void module_start_uart_0(void);

#endif
